package com.my.blog.website.service.impl;

import com.my.blog.website.dao.RechargeRecordVoMapper;
import com.my.blog.website.modal.Vo.RechargeRecordVo;
import com.my.blog.website.modal.Vo.RechargeRecordVoExample;
import com.my.blog.website.service.IRechargeRecordService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @author ：gyh
 * @date ：Created in 2020/10/11 0:13
 * @description：用户购买服务实现类
 * @modified By：gyh
 * @version: 1.0
 */
@Service
public class RechargeRecordServiceImpl implements IRechargeRecordService {

    @Resource
    private RechargeRecordVoMapper rechargeRecordVoMapper;

    @Override
    public void save(RechargeRecordVo rechargeRecord) {
        rechargeRecordVoMapper.insertSelective(rechargeRecord);
    }

    @Override
    public RechargeRecordVo getById(String outTradeNo) {
        RechargeRecordVoExample example = new RechargeRecordVoExample();
        RechargeRecordVoExample.Criteria criteria = example.createCriteria();
        criteria.andOrderNoEqualTo(outTradeNo);
        return rechargeRecordVoMapper.selectByExample(example).stream().findFirst().orElse(null);
    }

    @Override
    public RechargeRecordVo queryOrderInfo(String orderNo) {
        RechargeRecordVoExample example = new RechargeRecordVoExample();
        RechargeRecordVoExample.Criteria criteria = example.createCriteria();
        criteria.andOrderNoEqualTo(orderNo);
        return rechargeRecordVoMapper.selectByExample(example).stream().findFirst().orElse(null);
    }
}
